package com.ptszyxx.popose.module.base.login;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.ptszyxx.popose.BR;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ActivityLoginCodeBinding;
import com.ptszyxx.popose.module.base.login.vm.LoginCodeVM;
import com.ysg.base.BaseActivity;
import com.ysg.http.data.AppViewModelFactory;

public class LoginCodeActivity extends BaseActivity<ActivityLoginCodeBinding, LoginCodeVM> {
    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_login_code;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public LoginCodeVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(LoginCodeVM.class);
    }

    @Override
    public void initData() {
        super.initData();
    }

    @Override
    public void initViewObservable() {
        viewModel.uc.onSendCodeEvent.observe(this, o -> startTime());
    }

    /**
     * 短信倒计时
     */
    private void startTime(){
        binding.tvSendCode.startTimeCountDown();
    }

}
